package com.zzy.excel;

import org.apache.poi.common.usermodel.HyperlinkType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Hyperlink;

public class ExcelHyperLink {


    /** 设置 超链接 最好使用  excel 2007  xlsx   */
    public static Cell setHyperLink(HSSFWorkbook workbook,Cell cell){
        CreationHelper creationHelper = workbook.getCreationHelper();
        Hyperlink link = creationHelper.createHyperlink(HyperlinkType.URL);
        link.setAddress("www.baidu.com");
        cell.setHyperlink(link);
        cell.setCellFormula("百度（链接）");
        return  cell;
    }
}
